<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>员工基本信息</title>
<link rel="icon" href="<c:url value='/imgs/logo.ico' />" />
<link type="text/css" rel="stylesheet" href="<c:url value='/css/index.css' />" />
<link type="text/css" rel="stylesheet" href="<c:url value='/css/list.css' />" />
<script type="text/javascript" charset="utf-8" src="<c:url value='/scripts/jquery-2.1.0.js'/>"></script>
</head>
<body>
	<div class="container">
		<%@ include file="/jsps/top.jsp"%>
		<div class="main">
			<div class="content">
				<h2>员工基本信息</h2>
				<div class="fun">
					<input class="query" type="text" name="empid" placeholder="请输入查询的工号" /><input class="searchBtn" type="button" value="搜索"/>
					<input class="addBtn" type="button" value="添加员工"/>
				</div>
				<table class="listTable employee">
					<tr class="listTitle">
						<td>机构号</td>
						<td>工号</td>
						<td>姓名</td>
						<td>身份证号</td>
						<td>权限</td>
						<td>状态</td>
						<td>基本操作</td>
					</tr>
					<c:forEach items="${pb.beanList }" var="employee">
					<tr>
						<td>${employee.mechanism.mechid }</td>
						<td class="empid">${employee.empid }</td>
						<td>${employee.name }</td>
						<td>${employee.idnumber }</td>
						<td>
							<c:if test="${employee.power=='1' }">
								普通权限
							</c:if>
							<c:if test="${employee.power=='0' }">
								管理员权限
							</c:if>
						</td>
						<td>
							<c:if test="${employee.state=='0' }">
								任职状态
							</c:if>
							<c:if test="${employee.state=='1' }">
								离职状态
							</c:if>
						</td>
						<td>
							<a href="<c:url value='/queryEmployee?type=3&empid=${employee.empid }' />">详情</a> | 
							<a href="<c:url value='/queryEmployee?type=2&way=3&empid=${employee.empid }' />">修改</a> | 
							<a class="delete" href="#">删除</a>
						</td>
					</tr>
					</c:forEach>
				</table>
				<%@ include file="/jsps/page.jsp"%>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$(function(){
			$(".top .title").click(function(){
				location.href="<c:url value='/index.jsp'/>";
			});	
			
			$(".main .fun .searchBtn").click(function(){
				var empid = $("input[name='empid']").val();
				window.location.href="/FaceAttendSystem/queryEmployee?type=1&empid="+empid+"&pc=1";
			});
			
			$(".main .fun .addBtn").click(function(){
				window.location.href="<c:url value='/queryEmployee?type=2&way=2' />";
			});
			
			$(".main .listTable .delete").click(function(){
				var flag = false;
				if(confirm("您确定要删除吗？")){
					flag = true;
				}
				if(flag==true){
					var empid = $(this).parent().parent().find('.empid').text();
					var path = window.location.href;
					$.ajax({
						type:"post",
						url:"<c:url value='/deleteEmployee' />",
						data:{"empid":empid},
						dataType:"json",
						success:function(data){
							if(data.flag=="0"){
								alert("删除失败!");
							}else{
								alert("删除成功!");
							}
							window.location.href=path;
							window.location.reload;
						},
						error:function(){
							alert("操作失败，请重试！");
						}
					});
				}
			}); 
		});
	</script>
</body>
</html>

